Repository navigation
Android perf metrics: example-app fixes, per-presentation RN host and TTFD hook - #493
Merged
hurali97 merged 6 commits intoOct 15, 2026
Conversation
Static source directories added through the variant API are not task inputs, so a rebuilt JS bundle left mergeAssets/packageResources UP-TO-DATE and the AAR shipped the previous bundle. Register the generated assets/res dirs (including the expo-updates resources) as inputs of those tasks.
adrian-callstack
force-pushed
the
adrian/perf-metrics-android-testing
branch
from
October 14, 2026 19:06
fa10188 to
f1b0f89
Compare
Pad the postMessage tab with the safe-area insets (and the bottom tab inset) so its content is not drawn under the status bar or tab bar when the Expo surface is hosted full screen. ExpoApp56's Jest setup mocks react-native-safe-area-context, since the tests render the tab without a SafeAreaProvider.
Move the embedded RN fragment out of MainActivity's scroll view into a dedicated ReactNativeActivity pushed from an "Open React Native" button, mirroring RNAppScreen on iOS. Each launch creates a new fragment, so every presentation reports its own TTID/TTFD. The activity now owns the BrownfieldNavigation delegate. Detox suites open the RN screen through the new button instead of scrolling the native shell, and window-focus recovery no longer brings MainActivity to the front while another app activity is resumed.
…on top Give the "Open React Native" button an accessibility identifier so the Detox suites tap it directly instead of matching by text, and move the postMessage toast above the NavigationView so it stays visible while the pushed RN screen is in front.
Add a useMarkFullyDisplayed hook to RNApp, ExpoApp56 and ExpoApp57 and call it from each root (and the Expo Router root). It marks the presentation fully displayed after DEMO_FULL_DISPLAY_DELAY_MS, which stands in for the data a real screen would load first. ExpoApp56 never called markFullyDisplayed even though its Android flavor waits for full display, so it reported no display metrics at all.
adrian-callstack
force-pushed
the
adrian/perf-metrics-android-testing
branch
from
October 15, 2026 01:01
f1b0f89 to
9236fd7
Compare
The vanilla settings/referrals tests tapped an RN <Button> with Detox
synchronization on. The press queues ripple view commands, and onPress
pushes a native activity straight away; once ReactNativeActivity pauses,
Fabric never mounts those commands, so FabricUIManagerIdlingResources
stays busy ("View command mount items pending: 1") and the tap times out
intermittently.
Tap with sync off and wait for the native screen through UIAutomator,
which the tests already did for the assertion.
adrian-callstack
marked this pull request as ready for review
October 15, 2026 06:45
hurali97
approved these changes
Oct 15, 2026
hurali97
added a commit
that referenced
this pull request
Oct 16, 2026
* feat: initial impl * feat: add performance metrics * fix: expo updates * feat: add perf metrics to android * feat: use perf metrics * Android perf metrics: example-app fixes, per-presentation RN host and TTFD hook (#493) * fix(bgp): track RN bundle dirs as merge task inputs Static source directories added through the variant API are not task inputs, so a rebuilt JS bundle left mergeAssets/packageResources UP-TO-DATE and the AAR shipped the previous bundle. Register the generated assets/res dirs (including the expo-updates resources) as inputs of those tasks. * fix(Expo): respect safe-area insets on the postMessage tab Pad the postMessage tab with the safe-area insets (and the bottom tab inset) so its content is not drawn under the status bar or tab bar when the Expo surface is hosted full screen. ExpoApp56's Jest setup mocks react-native-safe-area-context, since the tests render the tab without a SafeAreaProvider. * feat(AndroidApp): host React Native in a full-screen ReactNativeActivity Move the embedded RN fragment out of MainActivity's scroll view into a dedicated ReactNativeActivity pushed from an "Open React Native" button, mirroring RNAppScreen on iOS. Each launch creates a new fragment, so every presentation reports its own TTID/TTFD. The activity now owns the BrownfieldNavigation delegate. Detox suites open the RN screen through the new button instead of scrolling the native shell, and window-focus recovery no longer brings MainActivity to the front while another app activity is resumed. * test(AppleApp): open RN via accessibility id, keep postMessage toast on top Give the "Open React Native" button an accessibility identifier so the Detox suites tap it directly instead of matching by text, and move the postMessage toast above the NavigationView so it stays visible while the pushed RN screen is in front. * feat(examples): mark TTFD from every example app via a shared hook Add a useMarkFullyDisplayed hook to RNApp, ExpoApp56 and ExpoApp57 and call it from each root (and the Expo Router root). It marks the presentation fully displayed after DEMO_FULL_DISPLAY_DELAY_MS, which stands in for the data a real screen would load first. ExpoApp56 never called markFullyDisplayed even though its Android flavor waits for full display, so it reported no display metrics at all. * test(AndroidApp): tap RN-to-native navigation buttons with sync off The vanilla settings/referrals tests tapped an RN <Button> with Detox synchronization on. The press queues ripple view commands, and onPress pushes a native activity straight away; once ReactNativeActivity pauses, Fabric never mounts those commands, so FabricUIManagerIdlingResources stays busy ("View command mount items pending: 1") and the tap times out intermittently. Tap with sync off and wait for the native screen through UIAutomator, which the tests already did for the assertion. * refactor: use generated source dir * docs: move performance metrics guide to the docs website Add a Performance Metrics guide covering startup timings, TTID, TTFD, JS FPS and UI FPS. Document markFullyDisplayed in the JavaScript API reference and remove PERFORMANCE.md. * test: stub RN bundle tasks with output dirs in Gradle plugin fixtures The plugin wires createBundle<Variant>JsAndAssets jsBundleDir/resourcesDir outputs as generated sources and fails fast without them, so plain tasks.register stubs broke the AGP compatibility matrix. * fix(ios): forget earlier bundle timings when a JS bundle load fails A failed reload left didLoadBundle and latestTimings from the previous load, so a new onBundleLoaded registration got stale timings right away. * chore(ios): restore RNApp Podfile.lock after a bad merge The merge duplicated the boost, BrownfieldNavigation and React-bridging entries, which made pod install crash. * fix: pass brownfieldPresentationID only to measured presentations Views, view controllers and fragments created without the metrics APIs now keep their initial props as is and create no display session, on both iOS and Android. * fix(ios): start initial display only after the React Native root exists With Expo Updates, view() returns a placeholder and inserts the root later. The appearance probe sat in the placeholder, so initial display could complete before the root existed, or when its creation failed. The probe now goes into the real root, and the view controller reports appearance only after that. * test(e2e): keep Detox sync off on the AppleApp native shell AppleApp preloads the JS bundle at launch, and the RN view now sits behind the Open React Native button. DetoxSync keeps the app busy on React Native (bundle load) until RN content appears, so re-enabling sync on the native shell made the app never go idle and every iOS test timed out. Sync is turned back on by openReactNative once the RN screen is visible. * test(e2e): open the AppleApp RN screen with a coordinate tap Detox's element tap injects a synthesized touch at the accessibility activation point, which SwiftUI's NavigationLink ignores: the tap was reported as successful, but the RN screen was never pushed. Tap the center of the Open React Native button through XCUITest (device.tap) instead, which delivers a real touch. --------- Co-authored-by: Adrian <138571007+adrian-callstack@users.noreply.github.com> Co-authored-by: Adrian Buciuman <adrian.buciuman@callstack.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on
hur/feat/perf-metrics. Testing the Android side of the perf metrics turned up a few fixes, plus changes to the example apps and tests that make TTID/TTFD easier to check. Each commit stands on its own, so reviewing commit by commit is easiest.Commits
fix(bgp): track RN bundle dirs as merge task inputsThe variant API doesn't treat static source dirs as task inputs. After a JS bundle rebuild,
merge<Variant>Assets/package<Variant>Resourcesstayed UP-TO-DATE and the AAR shipped the previous bundle. This commit registers the generated assets/res dirs, including the expo-updates resources, as inputs.fix(Expo): respect safe-area insets on the postMessage tabPads the tab with safe-area insets so its content isn't drawn under the system bars when the Expo surface is full screen. ExpoApp56's Jest setup mocks
react-native-safe-area-context. This commit comes before 3 on purpose: without it, commit 3 breaks the Android Expo postMessage e2e test, because the bubble ends up under the system bars.feat(AndroidApp): host React Native in a full-screen ReactNativeActivityMoves the RN fragment out of
MainActivity's scroll view into aReactNativeActivityopened from an "Open React Native" button, the same pattern asRNAppScreenon iOS. Every launch is a new presentation, so each one reports its own TTID/TTFD. The Android Detox suites now tap the button instead of scrolling the native shell. Window-focus recovery no longer bringsMainActivityto the front while another app activity is resumed.test(AppleApp): open RN via accessibility id, keep postMessage toast on topAdds an accessibility id on the "Open React Native" button, used by the iOS suites. The postMessage toast moves above the
NavigationViewso it stays visible on the pushed RN screen.feat(examples): mark TTFD from every example app via a shared hookAdds
useMarkFullyDisplayedto RNApp, ExpoApp56 and ExpoApp57.DEMO_FULL_DISPLAY_DELAY_MS = 500stands in for the data a real screen would load first. ExpoApp56 never calledmarkFullyDisplayed, but its Android flavor setsWAIT_FOR_FULL_DISPLAY = true, so it reported no display metrics at all. This commit also fixes the 4 RNApp unit tests that fail on the base branch (route.paramsis undefined in tests).test(AndroidApp): tap RN-to-native navigation buttons with sync offFixes intermittent failures in the vanilla settings/referrals tests, which also fail on the base. The tests tapped an RN
<Button>with Detox sync on. On Android the press queues ripple view commands, andonPresspushes a native activity straight away. Once the RN host activity pauses, Fabric never mounts those commands, soFabricUIManagerIdlingResourcesstays busy (View command mount items pending: 1) and the tap times out after ~200 s. The newtapAndWaitForNativeScreenhelper taps with sync off and waits for the native screen through UIAutomator, which the tests already used for the assertion.Testing
Unit / static: run on every commit
cd34c8etest:apps: RNApptest:apps: ExpoApp56, shared-teststest:packagesktlintCheckThese failures are all already on the base branch:
packages/cli:strip-framework-binary.test.tsfails with "Calling the test function inside another test function is not allowed".ktlintCheck: fails, and a task that depends onktlintFormatre-indents ~39 plugin files to 2 spaces. Agradle-plugins/react/brownfield/.editorconfigwith 4-space indent fixes it. It's also needed locally, becauseyarn brownfield:plugin:publish:localruns ktlint. I'll raise it againstmainseparately.E2E (Detox, local)
Android:
Pixel_10_Proemulator, release APKs. iOS: Xcode 26.6, iPhone 17 Pro on iOS 26.5 (also tried iOS 27), on a macOS 27 host.cd34c8ecd1d0bc¹ Intermittent idle timeout in the settings/referrals navigation tests (
View command mount items pending: 1), also present on the base. Fixed by commit 6: the fix was verified with one--rebuildand two--test-onlyruns on the tip, all 4/4, with no busy-app warnings.² Local environment problem, and the same on the base branch. Two things went wrong:
CODE_SIGNING_ALLOWED=NO, so the embedded frameworks (ExpoFont.framework, …) are unsigned. dyld on this machine rejects them at launch (Library not loaded: @rpath/ExpoFont.framework/ExpoFont … code signature). Ad-hoc signing the frameworks and the app after the build (codesign --force --sign -) fixes the crash.beforeAll(waitForAppleAppReady) never sees the app go idle, so every test hits the 720 s hook timeout. Detox reports this as "can't seem to connect".The base
cd34c8efails identically (expo57, signed build, iOS 26.5: 0/3, same hook timeout), so this isn't caused by this PR. The likely cause is the host OS: this machine runs macOS 27.0.1, and CI runsmacos-26, where the AppleApp vanilla / Expo 57 / Expo 58 e2e jobs passed onmain-based branches on 2026-10-13/14. The vanilla/expo56 iOS rows are from earlier, unsigned runs on iOS 27, which failed at launch the same way. iOS needs verifying in CI or on another machine.Two local-runner issues also came up, neither caused by this PR:
scripts/ci-local-androidapp-android-e2e.shlooks forbrownfieldlib-…-release.aar, but RNApp'sdev/prodflavors (feat: add product flavor and dimension to RN App #386) publish…-devRelease.aar. CI already usesdevRelease(.github/actions/androidapp-road-test/action.yml). I worked around it locally with--rebuild.LANG/LC_ALL) for CocoaPods.To check the metrics by hand: open the RN screen on a Release build and look at the
AndroidApplogcat tag.[TTFD]should arrive about 500 ms after[TTID].jsBundleLoadTimeshows asunavailablein Release because the bundle is embedded, which is expected (seePERFORMANCE.md).